PDA

View Full Version : [CLOSED] Chart Not working



PriceRightHTML5team
Jul 18, 2013, 7:38 AM
Hi,

Below is my code

View:


@(X.Panel()
.Items(
X.Chart().Shadow(true).StyleSpec("background:#fff;")
.Animate(true)
.Store(X.Store()
//.Data(Model.ListScenarioSimuOutput)
.Model(X.Model()
.Fields(
X.ModelField().Name("Price"),
X.ModelField().Name("CountryName")
)
)
.Proxy(X.AjaxProxy()
.Url(Url.Action("GetDataForSimulation","Results"))
.Reader(X.JsonReader().Root("result"))
)

)
.Axes(
X.NumericAxis()
.Fields("Price")
.Grid(true)
.Title("Number of Hits")
.Minimum(0)
.Label(X.AxisLabel()
.Renderer(r => r.Handler = "return Ext.util.Format.number(value, '0,0');")
),
X.CategoryAxis()
.Position(Position.Bottom)
.Fields("CountryName")
.Title("Countries")
)
.Series(X.ColumnSeries()
.Axis(Position.Left)
.Highlight(true)
.XField("CountryName")
.YField("Price")
.Tips(X.ChartTip()
.TrackMouse(true)
.Width(140)
.Height(28)
.Renderer(r => r.Handler = "this.setTitle(storeItem.get('CountryName') + ': ' + storeItem.get('Price'));")
)
.Label(X.SeriesLabel()
.Display(SeriesLabelDisplay.InsideEnd)
.Field(new [] { "Price" })
.Orientation(Orientation.Horizontal)
.Color("#333")
.TextAnchor("middle")
.Renderer(r => r.Handler = "return Ext.util.Format.number(value, '0');")
)
)
)
)

In my MVC Controller i hvae following:


public ActionResult GetDataForSimulation()
{
var result = service.Getdata();
return this.Direct(result);
}

Getdata method give me list of some object which has properties "Price" and "CountryName" but my chart is not getting displayed.

Any reason please let me know

Thanks

Daniil
Jul 18, 2013, 7:40 AM
Hi @PriceRightHTML5team,

You should use a StoreResult.

Action

public ActionResult GetDataForSimulation()
{
return this.Direct(service.Getdata());
}

Also please replace

Root("result")
with

Root("data")

PriceRightHTML5team
Jul 18, 2013, 8:11 AM
Hi @PriceRightHTML5team,

You should use a StoreResult.

Action

public ActionResult GetDataForSimulation()
{
return this.Direct(service.Getdata());
}

Also please replace

Root("result")
with

Root("data")


Hi Daniil,

No Luck.Following are my changes:


@(X.Panel()
.Items(
X.Chart().Shadow(true).StyleSpec("background:#fff;")
.Animate(true)
.Store(X.Store().ID("Store1")
//.Data(Model.ListScenarioSimuOutput)
.Model(X.Model()
.Fields(
X.ModelField().Name("Price"),
X.ModelField().Name("CountryName")
)
)
.Proxy(X.AjaxProxy()
.Url(Url.Action("GetDataForSimulation","Results"))
.Reader(X.JsonReader().Root("data"))
)

)
.Axes(
X.NumericAxis()
.Fields("Price")
.Grid(true)
.Title("Number of Hits")
.Minimum(0)
.Label(X.AxisLabel()
.Renderer(r => r.Handler = "return Ext.util.Format.number(value, '0,0');")
),
X.CategoryAxis()
.Position(Position.Bottom)
.Fields("CountryName")
.Title("Countries")
)
.Series(X.ColumnSeries()
.Axis(Position.Left)
.Highlight(true)
.XField("CountryName")
.YField("MeanEstimatedPrice")
.Tips(X.ChartTip()
.TrackMouse(true)
.Width(140)
.Height(28)
.Renderer(r => r.Handler = "this.setTitle(storeItem.get('CountryName') + ': ' + storeItem.get('Price'));")
)
.Label(X.SeriesLabel()
.Display(SeriesLabelDisplay.InsideEnd)
.Field(new [] { "Price" })
.Orientation(Orientation.Horizontal)
.Color("#333")
.TextAnchor("middle")
.Renderer(r => r.Handler = "return Ext.util.Format.number(value, '0');")
)
)
)
)

Controller:


return this.Store(result);

Daniil
Jul 18, 2013, 8:20 AM
What is a GetDataForSimulation's response?

Daniil
Jul 18, 2013, 8:23 AM
There is no such a ModelField in the Store's Model.

.YField("MeanEstimatedPrice")

PriceRightHTML5team
Jul 18, 2013, 8:26 AM
There is no such a ModelField in the Store's Model.

.YField("MeanEstimatedPrice")

Ohh....sorry typo mistake... the model returns Price and not MeanEstimatedPrice.

the service returns a List<SomeObject> and this object has 2 properties:
1)Price
2)CountryName.

Not sure what's missing

Daniil
Jul 18, 2013, 8:31 AM
Please post an actual response of the GetDataForSimulation's call. You can inspect it using IE or Chrome Developers Tools or FireBug for FireFox.

PriceRightHTML5team
Jul 18, 2013, 8:37 AM
Please post an actual response of the GetDataForSimulation's call. You can inspect it using IE or Chrome Developers Tools or FireBug for FireFox.

Following is the response i get:


{"data":[{"ScenarioUUID":322,"CountryCD":11,"ScenarioSimulationOutputUUID":1474430,"ScenarioSimulationUUID":337,"ScenarioName":"","ScenarioCountryUUID":12394,"CountryName":"GERMANY","MonthNum":0,"Price":0.995309821428571,"MaxEstimatedPrice":0.995309821428571,"MinEstimatedPrice":0.995309821428571,"PriceTypeCd":2,"PriceTypeDesc":"Pharmacy Purchasing Price","MeanRevenue":182931.84061,"MaxRevenue":182931.84061,"MinRevenue":182931.84061,"PackCD":0,"PACK_DESC":"","PACK_CURRENCY_CD":54,"PACK_CURRENCY_DESC":"EUR","EXCHANGE_RATE":1.0,"LOCAL_MEAN_ESTIMATED_PRICE":0.99531,"LOCAL_MIN_ESTIMATED_PRICE":0.99531,"LOCAL_MAX_ESTIMATED_PRICE":0.99531,"LOCAL_MEAN_REVENUE":182931.84061,"LOCAL_MIN_REVENUE":182931.84061,"LOCAL_MAX_REVENUE":182931.84061,"CUMULATIVE_MEAN_REVENUE":182931.840611667,"CUMULATIVE_MIN_REVENUE":182931.840611667,"CUMULATIVE_MAX_REVENUE":182931.840611667,"CUMULATIVE_LOCAL_MEAN_REVENUE":182931.840612,"CUMULATIVE_LOCAL_MIN_REVENUE":182931.840612,"CUMULATIVE_LOCAL_MAX_REVENUE":182931.840612,"MONTH_YEAR":"2013-04-02T14:43:14","ScenarioCurrencyDesc":"EUR","STRENGTH_UNIT_DESC":"","MEAN_REVENUE_NPV":null,"MIN_REVENUE_NPV":null,"MAX_REVENUE_NPV":null,"LOCAL_MEAN_REVENUE_NPV":null,"LOCAL_MIN_REVENUE_NPV":null,"LOCAL_MAX_REVENUE_NPV":null,"CUMULATIVE_MEAN_REVENUE_NPV":null,"CUMULATIVE_MAX_REVENUE_NPV":null,"CUMULATIVE_MIN_REVENUE_NPV":null,"LOCAL_CUMULATIVE_MEAN_REVENUE_NPV":null,"LOCAL_CUMULATIVE_MAX_REVENUE_NPV":null,"LOCAL_CUMULATIVE_MIN_REVENUE_NPV":null,"TableName":"","IsFilterSet":false,"AuditDTO":{"CurrentUserId":0},"SearchText":"","CreatedBy":0,"CreatedTS":null,"UpdatedBy":0,"UpdatedTS":null},{"ScenarioUUID":322,"CountryCD":15,"ScenarioSimulationOutputUUID":1474637,"ScenarioSimulationUUID":337,"ScenarioName":"","ScenarioCountryUUID":12398,"CountryName":"ITALY","MonthNum":0,"Price":1.39397321428571,"MaxEstimatedPrice":1.39397321428571,"MinEstimatedPrice":1.39397321428571,"PriceTypeCd":2,"PriceTypeDesc":"Pharmacy Purchasing Price","MeanRevenue":111460.23958,"MaxRevenue":111460.23958,"MinRevenue":111460.23958,"PackCD":0,"PACK_DESC":"","PACK_CURRENCY_CD":54,"PACK_CURRENCY_DESC":"EUR","EXCHANGE_RATE":1.0,"LOCAL_MEAN_ESTIMATED_PRICE":1.393973,"LOCAL_MIN_ESTIMATED_PRICE":1.393973,"LOCAL_MAX_ESTIMATED_PRICE":1.393973,"LOCAL_MEAN_REVENUE":111460.23958,"LOCAL_MIN_REVENUE":111460.23958,"LOCAL_MAX_REVENUE":111460.23958,"CUMULATIVE_MEAN_REVENUE":111460.23958333301,"CUMULATIVE_MIN_REVENUE":111460.23958333301,"CUMULATIVE_MAX_REVENUE":111460.23958333301,"CUMULATIVE_LOCAL_MEAN_REVENUE":111460.239583,"CUMULATIVE_LOCAL_MIN_REVENUE":111460.239583,"CUMULATIVE_LOCAL_MAX_REVENUE":111460.239583,"MONTH_YEAR":"2013-04-02T14:43:14","ScenarioCurrencyDesc":"EUR","STRENGTH_UNIT_DESC":"","MEAN_REVENUE_NPV":null,"MIN_REVENUE_NPV":null,"MAX_REVENUE_NPV":null,"LOCAL_MEAN_REVENUE_NPV":null,"LOCAL_MIN_REVENUE_NPV":null,"LOCAL_MAX_REVENUE_NPV":null,"CUMULATIVE_MEAN_REVENUE_NPV":null,"CUMULATIVE_MAX_REVENUE_NPV":null,"CUMULATIVE_MIN_REVENUE_NPV":null,"LOCAL_CUMULATIVE_MEAN_REVENUE_NPV":null,"LOCAL_CUMULATIVE_MAX_REVENUE_NPV":null,"LOCAL_CUMULATIVE_MIN_REVENUE_NPV":null,"TableName":"","IsFilterSet":false,"AuditDTO":{"CurrentUserId":0},"SearchText":"","CreatedBy":0,"CreatedTS":null,"UpdatedBy":0,"UpdatedTS":null}], "total": 0}

Daniil
Jul 18, 2013, 1:16 PM
Please try to set up the following for the Panel.

.Height(300)
.Layout("fit")

PriceRightHTML5team
Jul 18, 2013, 1:43 PM
Please try to set up the following for the Panel.

.Height(300)
.Layout("fit")


Thanks Daniil it did work.
But now the bar's are not showing up.

Below is the graph image. don't know whats wrong.

6573.

Also i need the vertical bar to be numbered as 0.00,0.20,0.40,0.60 .... and so on since the Y-axis has the price.

Thanks

Daniil
Jul 18, 2013, 5:01 PM
Thanks Daniil it did work.
But now the bar's are not showing up.

Below is the graph image. don't know whats wrong.

6573.



I cannot reproduce. The two green columns for Germany and Italy are rendered for me. Tested with the trunk and FireFox.



Also i need the vertical bar to be numbered as 0.00,0.20,0.40,0.60 .... and so on since the Y-axis has the price.


You should use

.Renderer(r => r.Handler = "return Ext.util.Format.number(value, '0.00');")
for the NumericAxis.

PriceRightHTML5team
Jul 19, 2013, 7:04 AM
I cannot reproduce. The two green columns for Germany and Italy are rendered for me. Tested with the trunk and FireFox.



You should use

.Renderer(r => r.Handler = "return Ext.util.Format.number(value, '0.00');")
for the NumericAxis.

Hi Daniil its working.
The issue was in IE need to exclude mordnizr script to render the graphs.

Thanks

Also is there any way i can assign different colors to different countries.
for e.g: green - > Germany, Red -> Italy

Daniil
Jul 19, 2013, 12:06 PM
Please use a ColumnSeries's Renderer.

For example, if you apply this code

<Renderer Handler="if (record.data[this.yField] < 50) {
attributes.fill = 'red';
}

return attributes;" />
in this example, you will notice the difference.
http://examples2.ext.net/#/Chart/Column/Basic/