wxIshiko / wxCharts

A library to create charts in wxWidgets applications
https://www.wxishiko.com/wxCharts/
MIT License
114 stars 50 forks source link

how to redefine the color theme of column chart? #213

Closed rodingbao closed 10 months ago

rodingbao commented 10 months ago
dear all:

I want to  replace the defalut color theme of column chart
here is my code,   it's success to define the wxChartsDatasetTheme, but fail when I update the wxChartsDefaultTheme.  
can anyone comment or help improving?

wxVector<double> t_points;
for (size_t i = 0; i < points.size(); i++) {
  t_points.assign(points[i].begin(), points[i].end());

  wxChartsDatasetTheme *datasettheme = new wxChartsDatasetTheme();
  datasettheme->SetColumnChartDatasetOptions(wxColumnChartDatasetOptions(
      wxChartsPenOptions(wxColour(COLOR[i]), 2),
      wxChartsBrushOptions(wxColour(COLOR[i]))));
  wxChartsDefaultTheme->SetDatasetTheme(
      wxChartsDatasetId::CreateImplicitId(i),
      wxSharedPtr<wxChartsDatasetTheme>(datasettheme));

  wxChartsDoubleDataset::ptr dataset(
      new wxChartsDoubleDataset(seriesName[i], t_points));
  chartData->AddDataset(dataset);
}

Best regards BZG

Kvaz1r commented 10 months ago

What exactly doesn't work? Your code produce compile error, runtime error, silently doesn't work as expected?

First of all do it outside the loop, like I'd showed in this issue - #165

rodingbao commented 10 months ago

compile error, message as below.

C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../build-Release/family/main.cpp.o:main.cpp:(.rdata$.refptr.wxChartsDefaultTheme[.refptr.wxChartsDefaultTheme]+0x0): undefined reference to `wxChartsDefaultTheme'

Kvaz1r commented 10 months ago

compile error, message as below. C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../build-Release/family/main.cpp.o:main.cpp:(.rdata$.refptr.wxChartsDefaultTheme[.refptr.wxChartsDefaultTheme]+0x0): undefined reference to `wxChartsDefaultTheme'

Re-check that you're using correct version of the library

rodingbao commented 10 months ago

I download source code (master branch,https://codeload.github.com/wxIshiko/wxCharts/zip/refs/heads/main) from git, and complier the lib by myself, do you mean that my download link is incorrect?

rodingbao commented 10 months ago

when I link with the static lib, the error disappered. dont know what happend. just close the issue.